package problema025;


public class Fibonacci1000Digit {
	

	public static void main(String[] args){
		fib1000();
	}
	
	public static void fib1000(){
		int[] ant = new int[1100];
		int[] act = new int[1100];
		int[] prox = new int[1100];
		
		ant[0] = 1; 
		act[0] = 1;
		
		int res = 2;
		
		while(true){
			prox = sumar(ant,act);
			ant = act;
			act = prox;
			res++;
			if(llegue(prox)) break;
		}
		System.out.println(res);
		//imprimir(prox);		
	}
	
	public static int[] sumar(int[] ant, int[] act){
		int[] res = new int[1100];
		int suma = 0, carry = 0, va = 0;
		for(int i = 0; i < ant.length; i++){
			suma = ant[i] + act[i] + carry;
			va = suma % 10;
			res[i] = va;
			carry = (suma - va) / 10;
		}
		return res;
	}
	
	public static boolean llegue(int[] prox){
		boolean res = false;
		for(int i = 999; i < prox.length; i++){
			if(prox[i] > 0){
				res = true;
				break;
			}
		}
		return res;			
	}
	
	public static void imprimir(int[] res){
		for(int i = 1099; i >= 0; i--){
			System.out.print(res[i]);
		}
	}
	

}
